package cn.org.seventh.tools.test.testcase;

import java.io.File;
import java.net.URL;

import junit.framework.TestCase;

import org.generama.FreeMarkerTemplateEngine;
import org.generama.MetadataProvider;
import org.generama.TemplateEngine;
import org.generama.WriterMapper;
import org.generama.tests.SinkWriterMapper;
import org.xdoclet.QDoxMetadataProvider;

import cn.org.seventh.tools.plugin.MethodUrlMappingPlugin;
import cn.org.seventh.tools.plugin.MethodUrlViewPlugin;

/**
 * @author <a href="mailto:ji.li@symbio-group.com">Andy</a>
 * @since 2008-5-22 下午10:58:54
 */
public class RunPluginWeb extends TestCase {
	private WriterMapper writerMapper;
	private MetadataProvider metadataProvider;
	private TemplateEngine templateEngine;

	@Override
	protected void setUp() throws Exception {
		// TODO Auto-generated method stub
		super.setUp();
		writerMapper = new SinkWriterMapper();
		URL reader = getClass().getResource("/");
		String path = reader.getPath() + "../../src/test/java/cn/org/seventh/tools/test/manage";
		metadataProvider = new QDoxMetadataProvider(new File(path));
		templateEngine = new FreeMarkerTemplateEngine();
	}

	@Override
	protected void tearDown() throws Exception {
		// TODO Auto-generated method stub
		super.tearDown();
	}

	public void testGenerateUrlView() throws Exception {

		MethodUrlViewPlugin plugin = new MethodUrlViewPlugin(
				(FreeMarkerTemplateEngine) templateEngine,
				(QDoxMetadataProvider) metadataProvider, writerMapper);
		plugin.setMultioutput(false);
		plugin.start();
		System.out.println(((SinkWriterMapper) writerMapper).getContent());

	}

	public void testGenerateUrlMapping() throws Exception {

		MethodUrlMappingPlugin plugin = new MethodUrlMappingPlugin(
				(FreeMarkerTemplateEngine) templateEngine,
				(QDoxMetadataProvider) metadataProvider, writerMapper);
		plugin.setMultioutput(false);
		plugin.start();
		System.out.println(((SinkWriterMapper) writerMapper).getContent());
	}
}
